//
//  SourcesOrderListDetailVC.m
//  HuoFeiDaShipper
//
//  Created by mac on 2019/12/15.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "SourcesOrderListDetailVC.h"
#import "SourceListDetailCell.h"
#import "SourceListDetaiInfoCell.h"
#import "SourceLisLineCell.h"
#import "OrderListDetailModel.h"
#import "HCSStarRatingView.h"
#import "SeeImgsVC.h"
#import "OrderTraceListVC.h"
#import "SeeOtherFeeVC.h"
#import "CJWKWebViewVC.h"
#import "XLImageViewer.h"

@interface SourcesOrderListDetailVC ()<UITableViewDelegate,UITableViewDataSource>{
    UIView * _imgParent;
    UIView *_imgUnParent;
}
@property (nonatomic,strong) CJTableView *tableView;
@property (nonatomic,strong) NSMutableArray *modelArray;
@property (nonatomic,strong) NSMutableArray *modelDetail;

@property (nonatomic,strong) SourceListDetailCell *sourceListDetailCell;
@property (nonatomic,strong) SourceListDetaiInfoCell *sourceListDetaiInfoCell;

@property (nonatomic,strong) CJImageView *imgVStatueBg;
@property (nonatomic,strong) CJLabel *labStatue;
@property (nonatomic,strong) CJLabel *labStatueDetail; // 状态提示

@property (nonatomic,strong) HCSStarRatingView *viewRate;
@property (nonatomic,strong) CJView *viewStar;
@property (nonatomic,strong) CJLabel *labDriverName;
@property (nonatomic,strong) CJLabel *labStarNum; //得分
@property (nonatomic,strong) CJLabel *labHistoryOrderNums;
@property (nonatomic,strong) CJLabel *labCarLicense;
// 轨迹等
@property (nonatomic,strong) FlexTouchView *touchUploadOrder; // 装车单
@property (nonatomic,strong) UIView *viewLineUploadOrder;
@property (nonatomic,strong) UIView *touchUploadOrderImagView;
@property (nonatomic,strong) NSMutableArray *listImgs;
@property (nonatomic,strong) NSMutableArray *listUnImgs;
@property (nonatomic,strong) FlexTouchView *touchDownloadOrder; // 卸车单子
@property (nonatomic,strong) UIView *viewLineDownlloadOrder;
@property (nonatomic,strong) FlexTouchView *touchTranSportOrder;
//@property (nonatomic,strong) UIView *viewLineTranSportOrder;
@property (nonatomic,strong) FlexTouchView *touchCarTrack;  //车辆轨迹
// headerView
@property (nonatomic,strong) CJLabel *labOrderNum;
@property (nonatomic,strong) CJLabel *labShipperDetaiAddr;
@property (nonatomic,strong) CJLabel *labConsigneeDetailAddr;
@property (nonatomic,strong) CJLabel *labShipperName; // 发货人
@property (nonatomic,strong) CJLabel *labShipperPhone;
@property (nonatomic,strong) CJLabel *labConsigneeName;
@property (nonatomic,strong) CJLabel *labConsigneePhone;
@end

@implementation SourcesOrderListDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setTitleName:CJLString(@"运单详情")];
    [self setBackLeftButton:@""];
    
    self.sourceListDetailCell = [[SourceListDetailCell alloc]initWithFlex:nil reuseIdentifier:nil];
    self.sourceListDetaiInfoCell = [[SourceListDetaiInfoCell alloc]initWithFlex:nil reuseIdentifier:nil];
//    self.sourceLisLineCell = [[SourceLisLineCell alloc]initWithFlex:nil reuseIdentifier:nil];
    self.modelDetail = [[NSMutableArray alloc]init];
    self.modelArray = [[NSMutableArray alloc]init];
    [self.view addSubview:self.tableView];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self loadData];
}

- (void)btnClickDriverPhoneAction{
    OrderListDetailModel *orderListDetailModel = self.modelDetail[0];
    OrderDetailModel * orderDetail = orderListDetailModel.orderDetail;
    [CJControl clickPhoneWithPhoneNum:orderDetail.driverPhone];
}
/// 装车单
- (void)btnUpLoadOrderAction{
    OrderListDetailModel *orderListDetailModel = self.modelDetail[0];
 
    SeeImgsVC *vc = [SeeImgsVC new];
    vc.strTitle = @"装车单照片";
    vc.arrImgs = orderListDetailModel.fillImageInfoList;
    [self pushVc:vc];
}

/// xieche车单
- (void)btnDownLoadOrderAction{
    
    OrderListDetailModel *orderListDetailModel = self.modelDetail[0];
    SeeImgsVC *vc = [SeeImgsVC new];
    vc.arrImgs = orderListDetailModel.signImageInfoList;
    vc.strTitle = @"卸车单照片";
    [self pushVc:vc];
}

/// 运输单
- (void)btnTranSportOrderAction{
    
    OrderListDetailModel *orderListDetailModel = self.modelDetail[0];
    OrderTraceListVC *vc = [OrderTraceListVC new];
    vc.modelArray = orderListDetailModel.orderTraceList;
    [self pushVc:vc];
}

/// 车辆轨迹
- (void)btnCarTrackAction{
   
    NSString *strUrl = CJStringWithFormat(@"%@/admin/#/trackOfVehicleForMobile?orderCode=%@",CJBaseUrl,self.strCode);
    CJWKWebViewVC *vc = [[CJWKWebViewVC alloc]init];
    vc.strUrl = strUrl;
    vc.strTitle = @"车辆轨迹";
    [self pushVc:vc];
}

- (void)loadData{

    NSString *strUrl = CJStringWithFormat(@"%@/ntocc-tms-api/orderDetail/%@",CJBaseUrl,self.strCode); //1d78851c7b7d4243a219ce0831a75fce
    WS(ws);
    NSDictionary *dic = [[NSDictionary alloc]init];
    [[HDNetworking sharedHDNetworking] GET:strUrl parameters:dic success:^(id  _Nonnull responseObject) {

        DLog(@"==== %@",responseObject);
        NSError * error ;
        if (self.modelDetail.count > 0) {
            [self.modelDetail removeAllObjects];
        }

        OrderListDetailModel *model = [[OrderListDetailModel alloc] initWithDictionary:responseObject error:&error];
        [self.modelDetail addObject:model];
        [ws createTableView];
        OrderListDetailModel *orderListDetailModel = self.modelDetail[0];
        [self reloadImagView:orderListDetailModel.fillImageInfoList];
        [self reloadUnImagView:orderListDetailModel.signImageInfoList];
    } failure:^(NSError * _Nonnull error) {
        DLog(@"++++++++%@",error);

    }];

}
- (void)reloadImagView:(NSArray *)arrImgs{
    self.listImgs = [[NSMutableArray alloc]init];
    for (int i = 0; i < arrImgs.count; i++) {
        if ([CJControl getIsEmpty:arrImgs[i]]) {
        }else{
          [self.listImgs addObject:arrImgs[i]];
        }
    }
    if (self.listImgs.count > 0) {
        [self createView];
    }
}
- (void)reloadUnImagView:(NSArray *)arrImgs{
    self.listUnImgs = [[NSMutableArray alloc]init];
    for (int i = 0; i < arrImgs.count; i++) {
        if ([CJControl getIsEmpty:arrImgs[i]]) {
        }else{
            [self.listUnImgs addObject:arrImgs[i]];
        }
    }
    if (self.listUnImgs.count > 0) {
        [self createViewUntab];
    }
}

/// 创建tableview 等
- (void)createView{
   for (int i = 0; i < self.listImgs.count; i++) {
    
    UIImageView* cell = [[UIImageView alloc]init];
    cell.userInteractionEnabled = YES;
//        [cell enableFlexLayout:YES];
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToSeeBigCell:)];
    cell.tag = i + 1000;
    [cell enableFlexLayout:YES];
    [cell setLayoutAttrStrings:@[
                                 @"width",@"75",
                                 @"height",@"75",
                                 @"margin",@"1%",
                                 @"alignItems",@"center",
                                 @"justifyContent",@"center",
                                 ]];
    [cell setViewAttr:@"bgColor" Value:@"#E4E9ED"];
    [cell setViewAttr:@"borderRadius" Value:@"0"];
    [cell addGestureRecognizer:tap];
    [_imgParent insertSubview:cell atIndex:i];
    [_imgParent markDirty];

    [cell sd_setImageWithURL:[NSURL URLWithString:self.listImgs[i]] placeholderImage:[UIImage imageNamed:@"zcj_error_image"]];
}
}
- (void)createViewUntab{
   for (int i = 0; i < self.listUnImgs.count; i++) {
    
    UIImageView* cell = [[UIImageView alloc]init];
    cell.userInteractionEnabled = YES;
//        [cell enableFlexLayout:YES];
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToUnSeeBigCell:)];
    cell.tag = i + 100;
    [cell enableFlexLayout:YES];
    [cell setLayoutAttrStrings:@[
                                 @"width",@"75",
                                 @"height",@"75",
                                 @"margin",@"1%",
                                 @"alignItems",@"center",
                                 @"justifyContent",@"center",
                                 ]];
    [cell setViewAttr:@"bgColor" Value:@"#E4E9ED"];
    [cell setViewAttr:@"borderRadius" Value:@"0"];
    [cell addGestureRecognizer:tap];
       [_imgUnParent insertSubview:cell atIndex:i];
    [_imgUnParent markDirty];

       [cell sd_setImageWithURL:[NSURL URLWithString:self.listUnImgs[i]] placeholderImage:[UIImage imageNamed:@"zcj_error_image"]];
}
}
-(void)clickToSeeBigCell:(UIGestureRecognizer*)sender{
UIView* cell = sender.view;
    
[[XLImageViewer shareInstanse] showNetImages:self.listImgs index:(int)cell.tag - 1000 fromImageContainer:cell];
}
-(void)clickToUnSeeBigCell:(UIGestureRecognizer*)sender{
UIView* cell = sender.view;
    
    [[XLImageViewer shareInstanse] showNetImages:self.listUnImgs index:(int)cell.tag - 100 fromImageContainer:cell];
}

/// 创建tableview 等
- (void)createTableView{

    //    WS(ws);
    OrderListDetailModel *orderListDetailModel = self.modelDetail[0];
    OrderModel *orderModel = orderListDetailModel.order;
    OrderDetailModel *orderDetailModel = orderListDetailModel.orderDetail;
    
    CGRect rcFrame = CGRectMake(0, kTopHeight, [[UIScreen mainScreen] bounds].size.width, 0);
    FlexFrameView *header = [[FlexFrameView alloc] initWithFlex:[CJControl getUIWithNew] ? @"OrderListDetailHeaderViewNew":@"OrderListDetailHeaderView" Frame:rcFrame Owner:self];
    header.flexibleHeight = YES;

//    status (integer, optional): 运单状态：1已接单（带运输）/2已装货/3已卸货/4已核算(待打款)/5已完成（已完成）
    
    if ([CJControl getUIWithNew]) {
        
        switch (orderDetailModel.status) {
            case 1:
                self.labStatue.text = @"已接单";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yijiedan_detai_new"];
                self.labStatueDetail.text = @"您的订单已接单";
                break;
            case 2:
                self.labStatue.text = @"已装货";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yizhuanghuo_detail_new"];
                self.labStatueDetail.text = @"您的订单已装货";
                break;
            case 3:
                self.labStatue.text = @"已卸货";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yixiehuohuo_detail_new"];
                self.labStatueDetail.text = @"您的订单已卸货";
                break;
            case 4:
                self.labStatue.text = @"已核算";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yijiesuan_detail_new"];
                self.labStatueDetail.text = @"您的订单已核算";
                break;
            case 5:
                self.labStatue.text = @"已完成";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yidakuan_detail_new"];
                self.labStatueDetail.text = @"您的订单已完成";
                break;

            default:
                break;
        }
        
    }else{
        
        switch (orderDetailModel.status) {
            case 1:
                self.labStatue.text = @"已接单";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yijiedan_detai"];
                break;
            case 2:
                self.labStatue.text = @"已装货";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yizhuanghuo_detail"];
                break;
            case 3:
                self.labStatue.text = @"已卸货";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yixiehuohuo_detail"];
                break;
            case 4:
                self.labStatue.text = @"已核算";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yijiesuan_detail"];
                break;
            case 5:
                self.labStatue.text = @"已完成";
                self.imgVStatueBg.image = [UIImage imageNamed:@"zcj_yidakuan_detail"];
                break;

            default:
                break;
        }
    }

    self.labOrderNum.text = orderDetailModel.orderCode;
    self.labDriverName.text = orderDetailModel.driverName;
    
    if ([CJRegular getIsStrEmpty:orderDetailModel.driverName]) {
        self.labDriverName.hidden = YES;
    }else{
        self.labDriverName.hidden = NO;
    }
    
    [self.viewStar addSubview:self.viewRate];
    self.viewRate.value = orderDetailModel.driverAverage;
    self.labStarNum.text = CJStringWithFormat(@"%@",@(orderDetailModel.driverAverage).cj_description);
    self.labHistoryOrderNums.text = CJStringWithFormat(@"历史订单:%@单",@(orderDetailModel.driverHistoryCount).cj_description);
    if ([CJRegular getIsStrEmpty:orderDetailModel.vehicleLicense]) {
        
    }else{
        self.labCarLicense.text = CJStringWithFormat(@"%@",orderDetailModel.vehicleLicense);
    }

    //    IsLoadingConfirm. IsUnloadingConfirm
//    orderDetailModel.isLoadingConfirm =
//    @property (nonatomic,strong) FlexTouchView *touchUploadOrder; // 装车单
//    @property (nonatomic,strong) FlexTouchView *touchDownloadOrder; // 卸车单子
//    self.touchUploadOrderImagView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 150);
//    self.touchUploadOrderImagView.backgroundColor = [UIColor redColor];
//    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 100)];
//    view.backgroundColor = [UIColor blueColor];
//    [self.touchUploadOrderImagView addSubview:view];
    
    if (orderDetailModel.isLoadingConfirm == 0) {
        self.touchUploadOrder.hidden = YES;
        self.viewLineUploadOrder.hidden = YES;
    }else if (orderDetailModel.isLoadingConfirm == 1) {
        self.touchUploadOrder.hidden = NO;
        self.viewLineUploadOrder.hidden = NO;
    }
    
    if (orderDetailModel.isUnloadingConfirm == 0) {
        self.touchDownloadOrder.hidden = YES;
        self.viewLineDownlloadOrder.hidden = YES;
    }else{
        self.touchDownloadOrder.hidden = NO;
        self.viewLineDownlloadOrder.hidden = NO;
    }
    
    self.labShipperDetaiAddr.text = CJStringWithFormat(@"%@%@",orderModel.shipperAddress,orderModel.shipperDetailAddress);
    self.labConsigneeDetailAddr.text = CJStringWithFormat(@"%@%@",orderModel.consigneeAddress,orderModel.consigneeDetailAddress);
    self.labShipperName.text = orderModel.shipperName;
    self.labShipperPhone.text = orderModel.shipperPhone;
    self.labConsigneeName.text = orderModel.consigneeName;
    self.labConsigneePhone.text = orderModel.consigneePhone;

    [self.modelArray removeAllObjects];
    
  // ,@"isDetail":@"1"   ,@"isDetail":@"0"  1 详情  0图标
    [self.modelArray addObject:@{@"title":@"zcj_icon_goodsInfo",@"content":CJLString(@"货物信息") ,@"isDetail":@"0"}]; //图标
    [self.modelArray addObject:@{@"title":CJLString(@"货物名称"),@"content":orderDetailModel.coalTypeName ,@"isDetail":@"1"}];
    
    NSString *strCoalPriceName = CJStringWithFormat(@"元/%@",orderModel.coalUnitName);
    [self.modelArray addObject:@{@"title":@"货物单价",@"content":CJStringWithFormat(@"%@%@",@(orderModel.coalPrice).cj_money_description,strCoalPriceName) ,@"isDetail":@"1"}];
    
    [self.modelArray addObject:@{@"title":@"装车数量",@"content":CJStringWithFormat(@"%@%@",@(orderDetailModel.loadQuantity).cj_description,orderModel.coalUnitName),@"isDetail":@"1"}];
    [self.modelArray addObject:@{@"title":@"卸车数量",@"content":CJStringWithFormat(@"%@%@",@(orderDetailModel.unloadQuantity).cj_description,orderModel.coalUnitName),@"isDetail":@"1"}];
    
    //    [self.modelArray addObject:@{@"title":CJLString(@"合理损耗"),@"content": orderModel.limitWastageAmount == 0 ? @"不计": CJStringWithFormat(@"%@%@",@(orderModel.limitWastageAmount).cj_description ,orderModel.limitWastageAmount == 0 ? @"":[CJControl getThreeUnaryValueStr:orderModel.limitWastageTypeName]),@"isDetail":@"1"}];
    //
        if ([orderModel.limitWastageTypeName isEqualToString:@"不计"]) {
            [self.modelArray addObject:@{@"title":CJLString(@"合理损耗"),@"content":@"不计",@"isDetail":@"1"}];

        }else{
            [self.modelArray addObject:@{@"title":CJLString(@"合理损耗"),@"content": CJStringWithFormat(@"%@%@",@(orderModel.limitWastageAmount).cj_description ,orderModel.limitWastageTypeName),@"isDetail":@"1"}];
        }
        
    
    
    [self.modelArray addObject:@{@"title":CJLString(@"运输距离"),@"content":CJStringWithFormat(@"%@公里",@(orderModel.distance).cj_description) ,@"isDetail":@"1"}];
    
    [self.modelArray addObject:@{@"title":@"zcj_feeDetail",@"content":CJLString(@"费用信息") ,@"isDetail":@"0"}];//图标
    
//    [self.modelArray addObject:@{@"title":CJLString(@"货物总价"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.detailGoodsTotal).cj_money_description) ,@"isDetail":@"1"}];
    
    [self.modelArray addObject:@{@"title":@"承运单价",@"content":CJStringWithFormat(@"%@%@",@(orderDetailModel.realPrice).cj_money_description,orderModel.isTrunkName) ,@"isDetail":@"1"}];
    [self.modelArray addObject:@{@"title":@"成交单价",@"content":CJStringWithFormat(@"%@%@",@(orderDetailModel.taxPrice).cj_money_description,orderModel.isTrunkName) ,@"isDetail":@"1"}];
    
    // 已卸货之后
    if (orderDetailModel.status >= 3) {
        [self.modelArray addObject:@{@"title":@"结算数量",@"content":CJStringWithFormat(@"%@%@", @(orderDetailModel.settlementWeight).cj_money_description ,orderModel.coalUnitName) ,@"isDetail":@"1"}];
    }
    
    [self.modelArray addObject:@{@"title":CJLString(@"预估运费"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.taxFee).cj_money_description) ,@"isDetail":@"1"}];

    if (orderDetailModel.payTaxAmount > 0) {
        [self.modelArray addObject:@{@"title":CJLString(@"预付金额"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.payTaxAmount).cj_money_description) ,@"isDetail":@"1"}];
    }
    // 已卸货之后
    if (orderDetailModel.status >= 3) {
        [self.modelArray addObject:@{@"title":CJLString(@"应付运费"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.shipmentDeliveryFeePractical).cj_money_description) ,@"isDetail":@"1"}];
    }
    // 已核算
    if (orderDetailModel.status >= 4) {
        
        [self.modelArray addObject:@{@"title":CJLString(@"实付运费"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.shipmentActualFreight).cj_money_description) ,@"isDetail":@"1"}];
        [self.modelArray addObject:@{@"title":CJLString(@"应付现金"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.shipmentActualCash).cj_money_description) ,@"isDetail":@"1"}];
        
        [self.modelArray addObject:@{@"title":CJLString(@"合计付款"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.shipperDeliveryFee).cj_money_description) ,@"isDetail":@"1"}];
        
        [self.modelArray addObject:@{@"title":CJLString(@"异常费用"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.abnormalFee).cj_money_description) ,@"isDetail":@"1"}];
        
        [self.modelArray addObject:@{@"title":CJLString(@"其它费用"),@"content":CJStringWithFormat(@"%@元 >>",@(orderDetailModel.extraFee).cj_money_description) ,@"isDetail":@"1"}];
    }
    
    if (orderDetailModel.isInsure == 1) {
        [self.modelArray addObject:@{@"title":CJLString(@"投保金额"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.insuranceFee).cj_money_description) ,@"isDetail":@"1"}];
        [self.modelArray addObject:@{@"title":CJLString(@"保险费用"),@"content":CJStringWithFormat(@"%@元",@(orderDetailModel.insuranceFee).cj_money_description) ,@"isDetail":@"1"}];
    }
         
    [self.modelArray addObject:@{@"title":@"zcj_otherDetail",@"content":CJLString(@"其他信息"),@"isDetail":@"0"}];//图标
    
    [self.modelArray addObject:@{@"title":CJLString(@"接单时间"),@"content":CJStringWithFormat(@"%@",[CJControl getThreeUnaryValueStr:orderDetailModel.gmtCreated]) ,@"isDetail":@"1"}];
    [self.modelArray addObject:@{@"title":CJLString(@"装货时间"),@"content":CJStringWithFormat(@"%@",[CJControl getThreeUnaryValueStr:orderDetailModel.fillTime]) ,@"isDetail":@"1"}];
    [self.modelArray addObject:@{@"title":CJLString(@"卸货时间"),@"content":CJStringWithFormat(@"%@",[CJControl getThreeUnaryValueStr:orderDetailModel.signTime]) ,@"isDetail":@"1"}];
    
    if (orderDetailModel.status >= 4) {
        [self.modelArray addObject:@{@"title":CJLString(@"核算时间"),@"content":CJStringWithFormat(@"%@",[CJControl getThreeUnaryValueStr:orderDetailModel.settleTime])  ,@"isDetail":@"1"}];
    }
//    财务打款  春雷行动去点
//    if (orderDetailModel.status >= 5) {
//        [self.modelArray addObject:@{@"title":CJLString(@"打款时间"),@"content":CJStringWithFormat(@"%@",orderDetailModel.payTime) ,@"isDetail":@"1"}];
//    }
//    迭代去掉 21-08-13
//    [self.modelArray addObject:@{@"title":CJLString(@"开票方式"),@"content":CJStringWithFormat(@"%@",[CJControl getThreeUnaryValueStr:orderModel.billingTypeName]) ,@"isDetail":@"1"}];
    
    [self.modelArray addObject:@{@"title":CJLString(@"运输方式"),@"content":CJStringWithFormat(@"%@",[CJControl getThreeUnaryValueStr:orderModel.transportTypeName]) ,@"isDetail":@"1"}];

    [self.modelArray addObject:@{@"title":CJLString(@"运输要求"),@"content":CJStringWithFormat(@"%@",[CJRegular getIsStrEmpty:orderModel.coalName] ? @"暂无":[CJControl getThreeUnaryValueStr:orderModel.coalName]) ,@"isDetail":@"1"}];
    
    if (![CJRegular getIsStrEmpty:orderDetailModel.remark]) {
        [self.modelArray addObject:@{@"title":CJLString(@"备注"),@"content":CJStringWithFormat(@"%@",orderDetailModel.remark),  @"isDetail":@"1" }];
    }
    [header layoutIfNeeded];
    self.tableView.tableHeaderView = header;
    [self.tableView reloadData];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.modelArray.count;
}

/// <#Description#>
/// @param tableView <#tableView description#>
/// @param indexPath <#indexPath description#>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

//    OrderListDetailModel *orderListDetailModel = self.modelDetail[0];
//    OrderModel *orderModel = orderListDetailModel.order;
    NSDictionary *dic = self.modelArray[indexPath.row];
    NSString *isDetail = [CJControl getThreeUnaryValueStr:dic[@"isDetail"]];
      
    WS(ws);
    if ([isDetail isEqualToString:@"1"]) {
        
        static NSString *identifier = @"SourceListDetaiInfoCell";
        SourceListDetaiInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[SourceListDetaiInfoCell alloc] initWithFlex:nil reuseIdentifier:identifier];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        
        [cell setCellInfoWithDict:self.modelArray[indexPath.row]];
        cell.blockOtherFee = ^(id anyObject) {
            SeeOtherFeeVC *vc = [[SeeOtherFeeVC alloc] init];
            vc.strCode = self.strCode;
            [ws pushVc:vc];
        };
        return cell;
        
    }else{
        
        static NSString *identifier = @"SourceListDetailCell";
        SourceListDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[SourceListDetailCell alloc] initWithFlex:nil reuseIdentifier:identifier];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        
        [cell setCellInfoWithDict:self.modelArray[indexPath.row]];
        return cell;
    }

}

- (CJTableView *)tableView{
    if (!_tableView) {
        _tableView = CJTableView.tbInitFrameStyle(CGRectMake(0, kTopHeight + CJTableToTopHeight, SCREEN_WIDTH, SCREEN_HEIGHT-kTopHeight - CJTableToTopHeight),UITableViewStylePlain)
        .tbDelegate(self)
        .tbDataSource(self)
        .tbSetOther(YES)
        .tbEstimatedRowHeight(YES)
//        .tbMjHeadFooter(YES)
        ;
//        WS(ws);
//        _tableView.blockMjHeader = ^(BOOL isheader) {
//
//            if (isheader) {
//                [ws downRefresh];
//            } else {
//                [ws upRefresh];
//            }
//
//        };
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    
    return _tableView;
}

- (HCSStarRatingView *)viewRate{
    if (!_viewRate) {
      _viewRate =   [[HCSStarRatingView alloc]initWithFrame:CGRectMake(0,0,110,30)];
        _viewRate.tintColor = [UIColor cjStarRateColor];
        _viewRate.starBorderColor = [UIColor cjClearColor];
        _viewRate.emptyStarColor = [UIColor cjEmptyStarRateColor];
        _viewRate.backgroundColor = [UIColor cjClearColor];
        _viewRate.enabled = NO;
        _viewRate.maximumValue = 5;
        _viewRate.allowsHalfStars = YES;
        _viewRate.minimumValue = 0;
    }
    return  _viewRate;
}
@end

